import requests
url = 'https://www.baidu.com/'
res = requests.get(url)
print(res)  # <Response [200]>
# print(res.text) #  源代码  乱码.charset=utf-8

# ！！设置字符集
res.encoding = 'utf-8'

#写入文件
with open('./Test/crawler/baidu.html',mode='w',encoding='utf-8') as f:
    f.write(res.text)
print('successfully')
